package com.ls.demo.http.service.impl;

import com.google.gson.Gson;
import com.ls.demo.bean.AuthCommand;
import com.ls.demo.bean.Command;
import com.ls.demo.bean.RoomBoxInfo;
import com.ls.demo.enums.MessageAttrEnum;
import com.ls.demo.http.service.DownloadService;
import lombok.extern.java.Log;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 执行下载
 * @author liShan
 * @date 2019/9/4 22:48
 * @see MessageAttrEnum
 */
@Service("downloadAuthServiceImpl_10")
@Log
public class DownloadAuthServiceImpl implements DownloadService {

    @Override
    public String execute(String str, Command command) {
        Gson gson = new Gson();
        AuthCommand c = gson.fromJson(str, AuthCommand.class);
        log.info(c.toString());
        RoomBoxInfo boxInfo = c.getBoxInfo();
        c.assCommand(command);
        List<String> datas = new ArrayList<>();
        datas.add(Integer.toHexString(c.getType()));
        if (null != c.getScene()){
            datas.add(Integer.toHexString(c.getScene()));
        }
        command.setDataList(datas);
        return boxInfo.getBoxId();
    }
}
